<template>
  <div v-loading="setLoading" element-loading-text="拼命加载中">
    <div class="settings-thumb">
      <i class="iconfont icon-qingsao i-icon color-primary"></i>
      <h2 class="settings-name">是否显示制卡</h2>
      <el-switch v-model="dataForm.status" @change="checkChange" :active-value="1" :inactive-value="0" active-text="开启" class="switch" inactive-text="关闭"></el-switch>
    </div>
    <div class="settings-intro">
      <div class="settings-description">
        <span>
          <el-form label-width="80px">

          </el-form>
        </span>
      </div>
      <!--<div class="settings-button">
        <a class="f14 color-blue" href="javascript:;">按钮</a>
      </div> -->
      <div id="printOperateController"></div>
    </div>
  </div>

</template>

<script>
  export default {
    data () {
      return {
        setLoading:false,
        dataForm: {
                 id: 0,
                 sellerId: '',
                 status: '',
                 createTime: '',
                 createUserId: '',
                 updateTime: '',
                 updateUserId: ''
               },

      }
    },
   activated() {
      this.init()
   },
    methods: {
        checkChange(){
          this.$http({
                       url: this.$http.adornUrl(`/hotel/tsellerroomcard/${!this.dataForm.id ? 'save' : 'update'}`),
                       method: 'post',
                       data: this.$http.adornData({
                         'id': this.dataForm.id || undefined,
                         'sellerId': this.dataForm.sellerId,
                         'status': this.dataForm.status,
                         'createTime': this.dataForm.createTime,
                         'createUserId': this.dataForm.createUserId,
                         'updateTime': this.dataForm.updateTime,
                         'updateUserId': this.dataForm.updateUserId
                       })
                     }).then(({data}) => {
                       if (data && data.code === 0) {
                         this.$message({
                           message: '操作成功',
                           type: 'success',
                           duration: 1500,
                           onClose: () => {
                                           this.init();
                           }
                         })
          }
            })
        },
        init(){
          this.$http({
                    url: this.$http.adornUrl('/hotel/tsellerroomcard/list'),
                    method: 'get',
                    params: this.$http.adornParams({

                    })
                  }).then(({data}) => {
                    if (data && data.code === 0) {
                      if(data.page.list!=null&&data.page.list.length!=0){
                         this.dataForm = data.page.list[0]
                      }
                    } else {
                      this.dataForm = {}
                    }
                 })
        },
     }
    };
</script>
